/*
 * Copyright (c) 2011 Ball State University
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package edu.bsu.android.gtv.apps.bconnected.objects;

/**
 * Degree object
 * @author Kyle Parker, University Computing Services
 */
public class Degree implements Comparable<Degree> {
	private String degreeType;
	private String department;
	private String error;
	private String programOption;
	private String programType;
    
	public String getDegreeType() {		
		return degreeType;
	}
	public void setDegreeType(String value)  {
		this.degreeType = value.trim();
	}

	public String getDepartment() {		
		return department;
	}
	public void setDepartment(String value) {
		this.department = value.trim();
	}
	
	public String getError() {		
		return error;
	}
	public void setError(String value) {
		this.error = value.trim();
	}

	public String getProgramOption() {		
		return programOption;
	}
	public void setProgramOption(String value) {
		this.programOption = value.trim();
	}

	public String getProgramType() {		
		return programType;
	}
	public void setProgramType(String value) {
		this.programType = value.trim();
	}
	
	public Degree copy() {
		Degree copy = new Degree();
		copy.degreeType = degreeType;
		copy.department = department;
		copy.error = error;
		copy.programOption = programOption;
		copy.programType = programType;
		return copy;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;

		result = prime * result + ((degreeType == null) ? 0 : degreeType.hashCode());
		result = prime * result + ((department == null) ? 0 : department.hashCode());
		result = prime * result + ((error == null) ? 0 : error.hashCode());
		result = prime * result + ((programOption == null) ? 0 : programOption.hashCode());
		result = prime * result + ((programType == null) ? 0 : programType.hashCode());
		return result;
	}
	
	@Override
	public boolean equals(Object obj) {
		if (this == obj) { return true; }
		
		if (obj == null) { return false; }
		
		if (getClass() != obj.getClass()) { return false; }
		
		Degree other = (Degree) obj;
		
		if (degreeType == null)  {
			if (other.degreeType != null) { return false; }
		} else if (!degreeType.equals(other.degreeType)) { return false; }
		
		if (department == null) {
			if (other.department != null) { return false; }
		} else if (!department.equals(other.department)) { return false; }
		
		if (error == null) {
			if (other.error != null) { return false; }
		} else if (!error.equals(other.error)) { return false; }
		
		if (programOption == null)  {
			if (other.programOption != null) { return false; }
		} else if (!programOption.equals(other.programOption)) { return false; }
		
		if (programType == null) {
			if (other.programType != null) { return false; }
		} else if (!programType.equals(other.programType)) { return false; }
		
		return true;
	}

	public int compareTo(Degree another) {
		if (another == null) return 1;
		// sort descending, most recent first
		return another.programOption.compareTo(programOption);
	}
}
